<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <base href="<%=basePath%>">
    <link rel="stylesheet" href="static/component/pear/css/pear.css" />
    <link rel="stylesheet" href="static/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="static/css/public.css" media="all">
    <style type="text/css">
        .layui-table-cell {
            height: auto;
            line-height: 28px;
        }
    </style>
</head>
<body style="margin-left:50px">

<form class="layui-form" action="">
    <div class="layui-form-item">
        <div class="layui-input-block">
            <input style="width: 250px" type="hidden" name="supplierId" required  lay-verify="required" placeholder="请输入供应编号"  autocomplete="off" class="layui-input" value="${supplier.supplierId}" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">供应商编码</label>
        <div class="layui-input-block">
            <input style="width: 250px" type="text" name="supplierCode" required  lay-verify="required" placeholder="请输入供应商编码"  autocomplete="off" class="layui-input" value="${supplier.supplierCode}" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">供应商名称</label>
        <div class="layui-input-block">
            <input style="width: 250px"  type="text" name="supplierName"   required  lay-verify="required" placeholder="请输入供应商名称" autocomplete="off" class="layui-input" value="${supplier.supplierName}" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">介绍</label>
        <div class="layui-input-block">
            <input style="width: 250px" type="text" name="supplierDesc" required  lay-verify="required" placeholder="请输入介绍信息" autocomplete="off" class="layui-input" value="${supplier.supplierDesc}" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">联系人</label>
        <div class="layui-input-block">
            <input style="width: 250px" type="text" name="supplierContact" required  lay-verify="required" placeholder="请输入联系人" autocomplete="off" class="layui-input" value="${supplier.supplierContact}" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号码</label>
        <div class="layui-input-block">
            <input style="width: 250px" type="text" name="supplierPhone" required  lay-verify="phone" placeholder="请输入手机号码" autocomplete="off" class="layui-input" value="${supplier.supplierPhone}" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">地址</label>
        <div class="layui-input-block">
            <input style="width: 250px"   type="text" name="supplierAddress" required  lay-verify="required" placeholder="请输入地址" autocomplete="off" class="layui-input " value="${supplier.supplierAddress}" />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">创建时间</label>
        <div class="layui-input-block">
            <input style="width: 250px" type="datetime" name="creationDate" required  lay-verify="required" placeholder="请输入创建时间" autocomplete="off" class="layui-input userData" value="${supplier.creationDate}" />
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">

            <button type="button" class="layui-btn" lay-submit lay-filter="userUpdateForm">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script src="static/component/layui/layui.js"></script>
<script src="static/component/pear/pear.js"></script>
<script>

    layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var $ = layui.jquery;
        var form = layui.form;
        //对组件
        form.render('select');
        form.render('radio');
        form.render('checkbox');
        //日期时间选择器
        laydate.render({
            elem: '.userData'
            ,type: 'datetime'
        });



        //异步请求修改用户信息
        form.on('submit(userUpdateForm)',function (data){
            //发送异步请求修改
            $.post('supplier/updateSupplier',data.field,function (result){
                //回调
                if (result.success){
                    layer.msg(result.msg,{icon:1,time:1000},function(){
                        window.close();
                        parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                        parent.parent.location.reload(); // 父页面刷新
                        parent.layui.table.reload("user-table");
                    });
                }
            })
        });



        /**
         * 表单验证
         */
        form.verify({
            pass1: function(value, item){ //value：表单的值、item：表单的DOM对象

                if($(".userpass1").val()!=$(".userpass2").val()){
                    return '两次密码不一致';
                }


            }
            //我们既支持上述函数式的方式，也支持下述数组的形式
            //数组的两个值分别代表：[正则匹配、匹配不符时的提示文字]
            ,pass: [
                /^[\S]{6,12}$/
                ,'密码必须6到12位，且不能出现空格'
            ]
        });

    });
</script>

</body>
</html>